Skip to content

Comments

kpatch-build: fix Fedora 42+ kernel source directory nesting#1496

Open
oshoval wants to merge 2 commits intodynup:masterfrom
oshoval:fix-fedora42-kernel-source-nesting
Open

kpatch-build: fix Fedora 42+ kernel source directory nesting#1496
oshoval wants to merge 2 commits intodynup:masterfrom
oshoval:fix-fedora42-kernel-source-nesting

Conversation

@oshoval
Copy link

@oshoval oshoval commented Feb 24, 2026

Fixes #1497

Starting with Fedora 42, the kernel SRPM unpacks with an extra level of nesting:

BUILD/kernel-6.14.0-build/kernel-6.14/linux-6.14.0-63.fc42.x86_64/

The existing glob BUILD/kernel-*/linux-* only matches the traditional flat layout and misses it.

Fix

Extract source-finding into find_rpm_linux_srcdir() in a new kpatch-funcs.sh, sourced by kpatch-build:

  • One glob match → move it (flat layout — RHEL, CentOS, Fedora < 42)
  • Multiple matchesdie with diagnostic
  • Zero matchesfind -maxdepth 3 excluding configs/ dirs, requiring exactly one result (nested layout — Fedora 42+)

Tests

Unit tests in test/unit/test-fedora-source-nesting.sh source the function directly and simulate flat, nested, multi-match, empty, and too-deep layouts with real distro version patterns. Run standalone:

bash test/unit/test-fedora-source-nesting.sh

Not wired into the existing test/unit/Makefile (which is object-file based) — happy to integrate if preferred.

Tested

  • Unit tests pass (11 cases covering all code paths: flat, nested, multi-match, empty, too-deep, configs exclusion)
  • shellcheck clean
  • Verified the Fedora 42 SRPM BUILD directory layout matches the nested pattern tested above
  • Full e2e kpatch-build on Fedora 42 without --sourcedir (our test environment used --sourcedir which bypasses SRPM extraction — happy to run a stock-kernel e2e once there's a conceptual LGTM)
  • Older Fedora / RHEL — flat-layout glob and mv extracted as-is; unit tests verify against real RHEL 9 and Fedora 41 directory names (will e2e if required)

@oshoval oshoval changed the title kpatch-build: fix Fedora 42+ kernel source directory nesting WIP kpatch-build: fix Fedora 42+ kernel source directory nesting Feb 24, 2026
@oshoval oshoval force-pushed the fix-fedora42-kernel-source-nesting branch from 5446018 to 5bd7160 Compare February 24, 2026 05:51
@oshoval oshoval changed the title WIP kpatch-build: fix Fedora 42+ kernel source directory nesting kpatch-build: fix Fedora 42+ kernel source directory nesting Feb 24, 2026
@oshoval oshoval force-pushed the fix-fedora42-kernel-source-nesting branch 2 times, most recently from c59f132 to ac2e396 Compare February 25, 2026 04:05
@oshoval oshoval marked this pull request as ready for review February 25, 2026 04:13
oshoval and others added 2 commits February 25, 2026 06:25
Starting with Fedora 42, the kernel SRPM unpacks with an extra level
of nesting:

  BUILD/kernel-6.14.0-build/kernel-6.14/linux-6.14.0-63.fc42.x86_64/

The existing glob BUILD/kernel-*/linux-* only matches the traditional
flat layout and fails on this structure.

Extract the source-finding logic into find_rpm_linux_srcdir() in a new
kpatch-funcs.sh, using nullglob with a bash array to safely count
flat-glob matches:
- Exactly one match: move it (traditional RHEL/CentOS/Fedora < 42).
- Multiple matches: die with a clear diagnostic.
- Zero matches: search deeper with find -maxdepth 3, excluding
  configs/ directories, again requiring exactly one result.

Signed-off-by: Or Shoval <oshoval@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Simulate RPM BUILD directory layouts across distros to validate the
source extraction logic introduced in the previous commit:
- Flat layout (Fedora < 42, RHEL 9, aarch64 variant)
- Nested layout (Fedora 42+, aarch64 variant)
- configs/ directory exclusion
- Error cases: ambiguous matches, missing source, excessive depth

Signed-off-by: Or Shoval <oshoval@redhat.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kpatch-build fails on Fedora 42: cannot find kernel source directory

1 participant